home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
mail.altrad.com
/
2015.02.mail.altrad.com.tar
/
mail.altrad.com
/
TEST
/
office german
/
PROPLUS.WW
/
PROPLSWW.CAB
/
MSORES.DLL
/
226
/
657
< prev
next >
Wrap
Extensible Markup Language
|
2006-10-26
|
8KB
|
163 lines
<?xml version="1.0" encoding="UTF-8"?>
<!--
***************************************************************************
dlcxsd2template.xslt
Transform that creates a template from an XSD.
*************************************************************************** -->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ma="http://schemas.microsoft.com/office/2006/metadata/properties/metaAttributes"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"
xmlns:ct="http://schemas.microsoft.com/office/2006/metadata/contentType"
xmlns:dms="http://schemas.microsoft.com/office/2006/documentManagement/types"
xmlns:out = "output.xsl">
<xsl:output method="xml" encoding="utf-8" indent="yes" />
<xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl" />
<!-- Properties Root namespace -->
<xsl:variable name="rootNSUri">http://schemas.microsoft.com/office/2006/metadata/propertiesRoot</xsl:variable>
<xsl:variable name="rootPrefix">pr</xsl:variable>
<!-- Core properties namespace -->
<xsl:variable name="coreNSUri">http://schemas.openxmlformats.org/package/2006/metadata/core-properties</xsl:variable>
<xsl:variable name="corePrefix">core</xsl:variable>
<xsl:variable name="dctermsNSUri">http://purl.org/dc/terms/</xsl:variable>
<xsl:variable name="dctermsPrefix">dcterms</xsl:variable>
<xsl:variable name="dcNSUri">http://purl.org/dc/elements/1.1/</xsl:variable>
<xsl:variable name="dcPrefix">dc</xsl:variable>
<xsl:variable name="dcmitypeNSUri">http://purl.org/dc/dcmitype/</xsl:variable>
<xsl:variable name="dcmitypePrefix">dcmitype</xsl:variable>
<!-- WSS properties namespace -->
<xsl:variable name="propsNSUri" select="/ct:contentTypeSchema/xsd:schema[@ma:root='true']/@targetNamespace" />
<xsl:variable name="propsPrefix">p</xsl:variable>
<!-- XSI namespace -->
<xsl:variable name="xsiNSUri">http://www.w3.org/2001/XMLSchema-instance</xsl:variable>
<xsl:variable name="baseXPath">documentManagement/</xsl:variable>
<!-- WSS property namespaces -->
<xsl:variable name="nsDecls" select="/ct:contentTypeSchema/xsd:schema[@ma:root = 'true']/namespace::*[local-name() != 'xml']" />
<!-- Main template -->
<xsl:template match="/ct:contentTypeSchema | /xsd:schema">
<!-- Processing instructions -->
<xsl:processing-instruction name="mso-infoPathSolution">
<xsl:text>solutionVersion="1.0.0.1" productVersion="12.0.2303" PIVersion="1.0.0.0" href="template.xml"</xsl:text>
</xsl:processing-instruction>
<xsl:processing-instruction name="mso-application"><xsl:text>progid="InfoPath.Document"</xsl:text></xsl:processing-instruction>
<!-- Root properties node -->
<xsl:element name="{$rootPrefix}:properties" namespace="{$rootNSUri}">
<xsl:call-template name="NamespaceDeclarations" />
<xsl:choose>
<xsl:when test="/ct:contentTypeSchema">
<!-- Core properties node -->
<xsl:element name="{$corePrefix}:coreProperties" namespace="{$coreNSUri}">
<xsl:apply-templates mode="core" select="xsd:schema[@targetNamespace = $coreNSUri]/xsd:complexType/*/xsd:element"/>
</xsl:element>
<!-- WSS properties node -->
<xsl:element name="{$propsPrefix}:properties" namespace="{$propsNSUri}">
<xsl:element name="documentManagement">
<xsl:for-each select="xsd:schema[(not(@ma:root) or @ma:root = 'false') and @targetNamespace != $coreNSUri]/xsd:element">
<xsl:sort select="@ma:index" data-type="number" />
<xsl:call-template name="wss"/>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<!-- Core properties node -->
<xsl:element name="{$corePrefix}:coreProperties" namespace="{$coreNSUri}">
<xsl:apply-templates mode="core" select="xsd:complexType/*/xsd:element"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<!-- Namespace declarations -->
<xsl:template name="NamespaceDeclarations">
<xsl:for-each select="$nsDecls">
<xsl:attribute name="{local-name()}:_" namespace="{.}" />
</xsl:for-each>
</xsl:template>
<!-- Core property elements -->
<xsl:template match="xsd:element" mode="core">
<xsl:choose>
<xsl:when test="starts-with(@ref, concat($dctermsPrefix, ':'))">
<xsl:element name="{@ref}" namespace="{$dctermsNSUri}" />
</xsl:when>
<xsl:when test="starts-with(@ref, concat($dcPrefix, ':'))">
<xsl:element name="{@ref}" namespace="{$dcNSUri}" />
</xsl:when>
<xsl:when test="starts-with(@ref, concat($dcmitypePrefix, ':'))">
<xsl:element name="{@ref}" namespace="{$dcmitypeNSUri}" />
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$corePrefix}:{@name}" namespace="{$coreNSUri}" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- WSS property elements -->
<xsl:template name="wss">
<xsl:variable name="elementNSUri" select="current()/ancestor::xsd:schema/@targetNamespace" />
<xsl:variable name="elementPrefix" select="local-name($nsDecls[. = $elementNSUri])" />
<xsl:variable name="elementQName">
<xsl:value-of select="$elementPrefix" />
<xsl:text>:</xsl:text>
<xsl:value-of select="@name" />
</xsl:variable>
<xsl:choose>
<xsl:when test="xsd:simpleType">
<xsl:element name="{$elementQName}" namespace="{$elementNSUri}">
<xsl:choose>
<!-- write default value, except 'today' for datetime fields -->
<xsl:when test="@ma:default and (@ma:default != '[today]' or xsd:simpleType/xsd:restriction[@base != 'dms:DateTime'])">
<xsl:choose>
<xsl:when test="xsd:simpleType/xsd:restriction[@base='dms:Boolean']">
<xsl:value-of select="boolean(@ma:default)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@ma:default" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="@nillable='true'">
<xsl:attribute name="xsi:nil" namespace="{$xsiNSUri}">true</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:element>
</xsl:when>
<xsl:when test="xsd:complexType">
<xsl:choose>
<xsl:when test="xsd:complexType/xsd:complexContent/*[@base='dms:URL']">
<xsl:element name="{$elementQName}" namespace="{$elementNSUri}">
<xsl:element name="{$elementPrefix}:Url" namespace="{$elementNSUri}">
<xsl:if test="@nillable[. ='true']">
<xsl:attribute name="xsi:nil" namespace="{$xsiNSUri}">true</xsl:attribute>
</xsl:if>
</xsl:element>
<xsl:element name="{$elementPrefix}:Description" namespace="{$elementNSUri}" />
</xsl:element>
</xsl:when>
<xsl:when test="xsd:complexType/xsd:complexContent/*/@base[.='dms:MultiChoice' or .='dms:MultiChoiceFillIn' or .='dms:MultiChoiceLookup']">
<xsl:element name="{$elementQName}" namespace="{$elementNSUri}">
<xsl:element name="{$elementPrefix}:Value" namespace="{$elementNSUri}">
<xsl:value-of select="@ma:default" />
</xsl:element>
</xsl:element>
</xsl:when>
<xsl:when test="xsd:complexType/xsd:complexContent/*/@base[.='dms:User' or .='dms:UserMulti']">
<xsl:element name="{$elementQName}" namespace="{$elementNSUri}">
<xsl:element name="{$elementPrefix}:UserInfo" namespace="{$elementNSUri}">
<xsl:element name="{$elementPrefix}:DisplayName" namespace="{$elementNSUri}" />
<xsl:element name="{$elementPrefix}:AccountId" namespace="{$elementNSUri}">
<xsl:if test="@nillable[. ='true']">
<xsl:attribute name="xsi:nil" namespace="{$xsiNSUri}">true</xsl:attribute>
</xsl:if>
</xsl:element>
<xsl:element name="{$elementPrefix}:AccountType" namespace="{$elementNSUri}" />
</xsl:element>
</xsl:element>
</xsl:when>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>